// app/static/js/scripts.js
document.addEventListener('DOMContentLoaded', function() {
    // 为所有删除按钮添加确认提示
    const deleteButtons = document.querySelectorAll('button[onclick^="return confirm"]');
    deleteButtons.forEach(btn => {
        btn.addEventListener('click', function(e) {
            if (!confirm(this.getAttribute('onclick').replace('return confirm(', '').replace(')', ''))) {
                e.preventDefault();
            }
        });
    });
    
    // 为日期选择器设置默认值
    const dateInputs = document.querySelectorAll('input[type="date"]');
    dateInputs.forEach(input => {
        if (!input.value) {
            const today = new Date();
            const year = today.getFullYear();
            const month = String(today.getMonth() + 1).padStart(2, '0');
            const day = String(today.getDate()).padStart(2, '0');
            input.value = `${year}-${month}-${day}`;
        }
    });
});